//Author : Domichou
//Last modif. : 02:50

#include "world.hpp"
#include "Ai.hpp"
#include "FruitSaladAi.hpp"

#include "helper.h"


#define INFLUENCE_DANGERDIRECT      50

#define RAYON_INFLUENCE_MOB         5


void World::computeDanger()
{
    Fruit temp;

    for( map<id, Fruit>::iterator it = chunk.objects.begin(); it != chunk.objects.end(); it++ )
    {
        temp = it->second.type;

        for(int i = -1*RAYON_INFLUENCE_MOB;i <= RAYON_INFLUENCE_MOB; i++)
        {
            for(int j = -1*RAYON_INFLUENCE_MOB;j <= RAYON_INFLUENCE_MOB; j++)
            {
                if(exists(temp.position->x+i,temp.position->y+j))
                    at(temp.position->x+i,temp.position->y+j).danger_estimation = INFLUENCE_DANGERDIRECT * (RAYON_INFLUENCE_MOB+1-abs((i*j)/2));
            }
        }
    }
}
